'use strict';
module.exports = app => {
  const { router, controller } = app;
  router.get('/', controller.home.index);

  // login
  router.post('/api/v1/user/login', controller.user.login)
  router.post('/api/v1/upload', controller.upload.index);

  // library
  router.get('/api/v1/library/config', controller.library.get);
  router.put('/api/v1/library', controller.library.update);
  // user
  router.post('/api/v1/user', controller.user.add);
  router.put('/api/v1/user', controller.user.update);
  router.put('/api/v1/user/reset', controller.user.reset);
  router.put('/api/v1/user/change_password', controller.user.changePassword);
  router.delete('/api/v1/user', controller.user.delete);
  router.get('/api/v1/users', controller.user.list);
  router.post('/api/v1/user/verified', controller.user.verified);
  router.get('/api/v1/user/info', controller.user.get);

  // book_type
  router.post('/api/v1/type', controller.type.add);
  router.put('/api/v1/type', controller.type.update);
  router.delete('/api/v1/type', controller.type.delete);
  router.get('/api/v1/types', controller.type.list);
  router.get('/api/v1/types/tree', controller.type.tree);

  // book
  router.post('/api/v1/book', controller.book.add);
  router.put('/api/v1/book', controller.book.update);
  router.delete('/api/v1/book', controller.book.delete);
  router.get('/api/v1/books', controller.book.list);
  router.put('/api/v1/book/on_sale', controller.book.onSaleChange)

  // lend_info
  router.post('/api/v1/lend_info', controller.lend.add);
  router.put('/api/v1/lend_info', controller.lend.update);
  router.get('/api/v1/lend_info/calculate', controller.lend.calculate);
  router.post('/api/v1/lend_info/return', controller.lend.return);
  router.get('/api/v1/lend_infos', controller.lend.list);

  // announce
  router.post('/api/v1/announce', controller.announce.add);
  router.put('/api/v1/announce', controller.announce.update);
  router.delete('/api/v1/announce', controller.announce.delete);
  router.get('/api/v1/announces', controller.announce.list);

  // suggest
  router.post('/api/v1/suggest', controller.suggest.add);
  router.delete('/api/v1/suggest', controller.suggest.delete);
  router.get('/api/v1/suggests', controller.suggest.list);
  // 页面主入口
  router.get('/*', controller.home.index);
  router.options('/*', (ctx) => { ctx.body = { result: true } })
};